package BinarySearch;

public class BinarySearch {
    public static int search(int[]a,int target){
        return f(a,target,0,a.length-1);
    }
    private static int f(int[]a,int target,int i,int j){
        if(i > j){
            return -1;
        }
        int m = i + j >>>1;
        
        if(a[m] < target){
            return f(a,target,i+1,j);
        }
        else if(target < a[m]){
            return f(a,target,i,j-1);
        }
        else{
            return m;
        }
    }
}
